package com.atguigu.service.impl;

import com.atguigu.base.BaseMapper;
import com.atguigu.base.BaseServiceImpl;
import com.atguigu.entity.Permission;
import com.atguigu.helper.PermissionHelper;
import com.atguigu.mapper.PermissionMapper;
import com.atguigu.service.PermissionService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * @Author:hx
 * @DateTime:2022/10/4 13:52
 * @Description:
 */
@DubboService
public class PermissionServiceImpl extends BaseServiceImpl<Permission> implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public BaseMapper<Permission> getBaseMapper() {
        return permissionMapper;
    }

    @Override
    public List<String> findPermissionCodeListByAdminId(Long adminId) {
        return permissionMapper.findPermissionCodeListByAdminId(adminId);
    }

    @Override
    public List<Permission> findPermissionListByAdminId(Long adminId) {
        //获取所有权限
        List<Permission> permissionList = permissionMapper.findPermissionListByAdminId(adminId);
        //构建树形菜单
        permissionList = PermissionHelper.build(permissionList);
        return permissionList;
    }
}
